package com.wu.dms.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wu.dms.dao.entity.User;
import com.wu.dms.dao.sqlProvide.UserSqlProvider;
import com.wu.dms.dao.vo.CollectVo;
import com.wu.dms.dao.vo.UserPageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

/**
 * @author Cousin
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT " +
            "SUM(IF(sex = 1, 1, 0)) AS males, " +
            "SUM(IF(sex = 0, 1, 0)) AS females " +
            "FROM music.user")
    Map<String, Object> selectAllStatistics();
    @SelectProvider(type = UserSqlProvider.class,method = "queryUserCollectInPage")
    List<CollectVo> queryUserCollectInPage(@Param("userId") Long userId,@Param("pageNum") Integer pageNum,@Param("pageSize") Integer pageSize,@Param("searchWord") String searchWord,
                                           @Param("startDate") String startDate,@Param("endDate") String endDate);


    @SelectProvider(type = UserSqlProvider.class,method = "countUserCollectInPage")
    Long countUserCollectInPage(@Param("userId") Long userId,@Param("searchWord") String searchWord,
                                           @Param("startDate") String startDate,@Param("endDate") String endDate);
    @SelectProvider(type = UserSqlProvider.class,method = "queryUserInPage")
    List<UserPageVo> queryUserInPage(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize,
                                     @Param("searchWord") String searchWord,
                                     @Param("startDate") String startDate, @Param("endDate") String endDate);
    @SelectProvider(type = UserSqlProvider.class,method = "countUserInPage")
    Long countUserInPage(@Param("searchWord") String searchWord,
                         @Param("startDate") String startDate,@Param("endDate") String endDate);

}
